home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / DOS / PG / CL_STYLE.ZIP / DOSLIB08.CLA < prev    next >
Encoding:
Text File  |  1994-01-28  |  12.9 KB  |  268 lines

  1.                  Member('DOSLIB')
  2.                  Eject('Program Identification Section')
  3. !
  4. !  ┌──────────────────────┐
  5. !  │Program Identification├──────────────────────────────────────────────────────
  6. !  └──────────────────────┘
  7. !
  8. !  Program Name           : Calendar.Cla
  9. !  Program Description    : Pops-Up a Calendar and Returns a Date
  10. !  Version                : 1.00a
  11. !  Date                   : 24 Janurary 1994
  12. !  Programmer             : Trevor G. Leybourne
  13. !
  14. !  ┌──────────────────────┐
  15. !  │Invocation Structure  ├─────────────────────────────────────────────────────
  16. !  └──────────────────────┘
  17. !
  18. !  Functions Called       : Calendar       - Actual Pop-Up Calendar
  19. !
  20. !  ┌──────────────────────┐
  21. !  │Input/Output          ├─────────────────────────────────────────────────────
  22. !  └──────────────────────┘
  23. !
  24. !  Datafiles Read         : None
  25. !  Datafiles Updated      : None
  26. !
  27. !  ┌──────────────────────┐
  28. ! ┌┤Functional Description├────────────────────────────────────────────────────┐
  29. ! │└──────────────────────┘                                                    │
  30. ! │                                                                            │
  31. ! │ This program is simply a Pop-Up Calendar                                   │
  32. ! └────────────────────────────────────────────────────────────────────────────┘
  33. !
  34. !  ┌──────────────────────┐
  35. ! ┌┤Modification History  ├────────────────────────────────────────────────────┐
  36. ! │└──────────────────────┘                                                    │
  37. ! │ Ver. Date           Programmer               Summary of Changes            │
  38. ! ├────────────────────────────────────────────────────────────────────────────┤
  39. ! │                                                                            │
  40. ! │ 1.01 24-Jan-1994    Trevor G. Leybourne      Original Production Version   │
  41. ! │                                                                            │
  42. ! └────────────────────────────────────────────────────────────────────────────┘
  43. !
  44. OMIT('╝')
  45. ╔════════════════════════════════════════════════════════════════════════════╗
  46. ║ Calculator - Displays the Pop-Up Calculator                                ║
  47. ╚════════════════════════════════════════════════════════════════════════════╝
  48. Calendar           Function(Default:Date)
  49. !
  50. ! ---------------------------------------------------------------------------
  51. ! Local Variables
  52. ! ---------------------------------------------------------------------------
  53. !
  54.                    Group,Pre(Cal)           ! Group of Local Variables
  55. Date_Today           Long                   !   Todays Real Date
  56. Date_Selected        Long                   !   Actual Date Selected
  57. Date_Saved           Long                   !   Date Saved
  58. Show_Index           Long                   !   Screen Display Index
  59. Save_Index           Long                   !   Save the Index
  60. Day                  Long                   !   Current Day
  61. Month                Long                   !   Current Month
  62. Year                 Long                   !   Current Year
  63. Base_Date            Long                   !   Base Date
  64. Base_Col             Long                   !   Base Column
  65. Last_Day             Long                   !   Last Day of the Month
  66.                    .
  67.  
  68. Transform_Table    Group                    ! This Table Transforms Col Within Row
  69.                      String('<01,07,13,19,25,31,37>')
  70.                      String('<02,08,14,20,26,32,38>')
  71.                      String('<03,09,15,21,27,33,39>')
  72.                      String('<04,10,16,22,28,34,40>')
  73.                      String('<05,11,17,23,29,35,41>')
  74.                      String('<06,12,18,24,30,36,42>')
  75.                    .
  76. Transform_Array    Byte,Dim(42),Over(Transform_Table)
  77.  
  78. Month_Table        Group                    ! Names of the Months
  79.                      String('January  February March    April    ')
  80.                      String('May      June     July     August   ')
  81.                      String('SeptemberOctober  November December ')
  82.                    .
  83. Month_Array        String(9),Dim(12),Over(Month_Table)
  84. !
  85. ! ---------------------------------------------------------------------------
  86. ! Screen Declarations
  87. ! ---------------------------------------------------------------------------
  88. !
  89. Calendar_Screen  SCREEN(19,28),PRE(Scr),SHADOW,CUA,COLOR(1)
  90.                    !dimensions=25,80,25,80
  91.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  92.                    ROW(7,5)    PAINT(6,20),COLOR(15)
  93.                    ROW(1,1)    STRING('█{10}'),COLOR(3)
  94.                      COL(11)   STRING('Calendar'),COLOR(2)
  95.                      COL(19)   STRING('█{10}'),COLOR(3)
  96.                    ROW(5,5)    STRING('Su'),COLOR(6)
  97.                      COL(8)    STRING('Mo'),COLOR(6)
  98.                      COL(11)   STRING('Tu'),COLOR(6)
  99.                      COL(14)   STRING('We'),COLOR(6)
  100.                      COL(17)   STRING('Th'),COLOR(6)
  101.                      COL(20)   STRING('Fr'),COLOR(6)
  102.                      COL(23)   STRING('Sa'),COLOR(6)
  103.                    ROW(6,4)    STRING('▄{22}'),COLOR(78)
  104.                    ROW(13,4)   STRING('▀{22}'),COLOR(78)
  105.                    ROW(19,1)   STRING('█▄{26}█'),COLOR(3)
  106.                                REPEAT(6)
  107.                    ROW(7,4)      STRING('█'),COLOR(78)
  108.                    ROW(7,25)     STRING('█'),COLOR(78)
  109.                                .
  110.                                REPEAT(17)
  111.                    ROW(2,1)      STRING('█'),COLOR(3)
  112.                    ROW(2,28)     STRING('█'),COLOR(3)
  113.                                .
  114. Show_Actual_Date   ROW(3,5)    STRING(@s20),COLOR(8)
  115.                                REPEAT(6,7),EVERY(1,3),INDEX(Cal:Show_Index)
  116. Show_Calendar      ROW(7,5)      STRING(@n_2b)
  117.                      COL(5)      POINT(1,2),USE(?Select_Date),COLOR(42)
  118.                                .
  119.                    ROW(15,10)  BUTTON('  '),SHADOW,KEY(PgUpKey),USE(?Last_Month),COLOR(17,18,39,19,20)
  120.                      COL(4)    BUTTON('  '),SHADOW,KEY(CtrlPgUp),USE(?Last_Year),COLOR(17,18,39,19,20)
  121.                      COL(17)   BUTTON('  '),SHADOW,KEY(PgDnKey),USE(?Next_Month),COLOR(17,18,39,19,20)
  122.                      COL(22)   BUTTON('  '),SHADOW,KEY(CtrlPgDn),USE(?Next_Year),COLOR(17,18,39,19,20)
  123.                    ROW(17,4)   BUTTON('   Ok    '),SHADOW,KEY(EnterKey),USE(?Calendar_OK),COLOR(17,18,39,19,20)
  124.                      COL(17)   BUTTON('  Today  '),SHADOW,USE(?Goto_Today),COLOR(17,18,39,19,20)
  125.                  .
  126. !
  127. ! ---------------------------------------------------------------------------
  128. ! Code Section
  129. ! ---------------------------------------------------------------------------
  130. !
  131.                    Code
  132.                    GetStyles('Clarion.Sty')
  133.                    SetMouse(1,1)
  134.                    Open(Calendar_Screen)
  135.  
  136.                    If ~Omitted(1) then
  137.                       Cal:Date_Today    = Default:Date
  138.                       Cal:Date_Selected = Default:Date
  139.                       Cal:Date_Saved    = 0
  140.                    .
  141.                    If Cal:Date_Today    = 0 or Omitted(1) then
  142.                       Cal:Date_Today    = Today()
  143.                       Cal:Date_Selected = Today()
  144.                       Cal:Date_Saved    = 0
  145.                    .
  146.                    Do Display_Ptr
  147.  
  148.                    Loop
  149.                      Alert
  150.                      Alert(LeftKey,RightKey)
  151.                      Alert(HomeKey,UpKey)
  152.                      Alert(EndKey,DownKey)
  153.                      Alert(PgUpKey)
  154.                      Alert(PgDnKey)
  155.                      Cal:Date_Saved = Cal:Date_Selected
  156.                      Accept
  157. !
  158. !                    ---------------------------------------------------------
  159. !                    Check the Key that has been Pressed
  160. !                    ---------------------------------------------------------
  161. !
  162.                      Case Keycode()
  163.                      Of LeftKey
  164.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) - 1
  165.                         Do Display_Ptr
  166.                      Of RightKey
  167.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) + 1
  168.                         Do Display_Ptr
  169.                      Of UpKey
  170.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) - 7
  171.                         Do Display_Ptr
  172.                      Of DownKey
  173.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year) + 7
  174.                         Do Display_Ptr
  175.                      Of PgUpKey
  176.                         Cal:Month -= 1
  177.                         If Cal:Month < 1 then Cal:Month = 12; Cal:Year -=1.
  178.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
  179.                         Do Display_Ptr
  180.                      Of PgDnKey
  181.                         Cal:Month += 1
  182.                         If Cal:Month > 12 then Cal:Month = 1; Cal:Year +=1.
  183.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
  184.                         Do Display_Ptr
  185.                      .
  186. !
  187. !                    ---------------------------------------------------------
  188. !                    Check the selected Field
  189. !                    ---------------------------------------------------------
  190. !
  191.                      Case Field()
  192.                      Of ?Last_Month
  193.                         Cal:Month -= 1
  194.                         If Cal:Month < 1 then Cal:Month = 12; Cal:Year -=1.
  195.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
  196.                         Do Display_Calendar
  197.                      Of ?Last_Year
  198.                         Cal:Year -= 1
  199.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
  200.                         Do Display_Calendar
  201.                      Of ?Next_Month
  202.                         Cal:Month += 1
  203.                         If Cal:Month > 12 then Cal:Month = 1; Cal:Year +=1.
  204.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
  205.                         Do Display_Calendar
  206.                      Of ?Next_Year
  207.                         Cal:Year += 1
  208.                         Cal:Date_Selected = Date(Cal:Month,Cal:Day,Cal:Year)
  209.                         Do Display_Calendar
  210.                      Of ?Calendar_Ok
  211.                         Break
  212.                      Of ?Goto_Today
  213.                         Cal:Date_Selected = Today()
  214.                         Do Display_Ptr
  215.                         Select(?Select_Date)
  216.                      Of ?Select_Date
  217.                         Cal:Date_Selected = Date(Month(Cal:Date_Selected),Scr:Show_Calendar,Year(Cal:Date_Selected))
  218.                         Do Display_Ptr
  219.                    . .
  220.                    Alert
  221.                    Close(Calendar_Screen)
  222.                    Return(Cal:Date_Selected)
  223. !
  224. ! ---------------------------------------------------------------------------
  225. ! Check the Current Date Pointer and Redisplay the Calendar is Applicable
  226. ! ---------------------------------------------------------------------------
  227. !
  228. Display_Ptr        Routine
  229.  
  230.                    Scr:Show_Actual_Date = Center(Format(Cal:Date_Selected,@d4),Size(Scr:Show_Actual_Date))
  231.                    Cal:Day              = Day  (Cal:Date_Selected)
  232.                    Cal:Month            = Month(Cal:Date_Selected)
  233.                    Cal:Year             = Year (Cal:Date_Selected)
  234.  
  235.                    If Month(Cal:Date_Selected) <> Month(Cal:Date_Saved) or |
  236.                       Year (Cal:Date_Selected) <> Year (Cal:Date_Saved) then
  237.                       Do Display_Calendar
  238.                    Else
  239.                       If Day(Cal:Date_Selected) <> Day(Cal:Date_Saved) then
  240.                          Cal:Show_Index = Transform_Array[Day(Cal:Date_Selected)+Cal:Base_Col]
  241.                          If Scr:Show_Calendar = '' or Scr:Show_Calendar = '00' then
  242.                             Do Display_Calendar
  243.                    .  .  .
  244.                    Exit
  245. !
  246. ! ---------------------------------------------------------------------------
  247. ! Display the Calendar based on the Date in CAL:DATE_SELECTED
  248. ! ---------------------------------------------------------------------------
  249. !
  250. Display_Calendar   Routine
  251.  
  252.                    Cal:Save_Index = Cal:Show_Index
  253.                    Cal:Base_Date  = Date(Cal:Month,1,Cal:Year)-1
  254.                    Cal:Base_Col   = (Cal:Base_Date + 1) % 7
  255.                    Cal:Last_Day   = Day(Date(Cal:Month+1,1,Cal:Year)-1)
  256.  
  257.                    Loop I# = 1 to 42
  258.                      Cal:Show_Index    = Transform_Array[I#]
  259.                      Scr:Show_Calendar = ''
  260.                    .
  261.                    Loop I# = 1 to Cal:Last_Day
  262.                      Cal:Show_Index    = Transform_Array[I#+Cal:Base_Col]
  263.                      Scr:Show_Calendar = Format(I#,@n_2b)
  264.                    .
  265.                    Cal:Show_Index = Transform_Array[Cal:Day+Cal:Base_Col]
  266.                    Select(?Select_Date)
  267.                    Exit
  268.